package hottargui.domain.alpha;

import hottargui.domain.*;

public class AlphaRoundSequenceStrategyImpl implements RoundSequenceStrategy{

	private PlayerColor _currentColor;
	private State _currentState;
	private int round;
	private StateMachine _stm;


	public AlphaRoundSequenceStrategyImpl(StateMachine stm){
		_stm = stm; 
	}

	public PlayerColor turnCard() {

		_currentState = _stm.getState();

		_currentColor = _stm.getCurrentColor(); 
		round = _stm.getRoundNumber();

		if (_currentState==State.newGame) {
			_currentColor = PlayerColor.Red;
		}

		else if (_currentColor == PlayerColor.Red && _currentState==State.endTurn) {
			_currentColor = PlayerColor.Green;
		}

		else if (_currentColor == PlayerColor.Green && _currentState==State.endTurn) 
			_currentColor = PlayerColor.Blue;

		else if (_currentColor == PlayerColor.Blue && _currentState==State.endTurn) 
			_currentColor = PlayerColor.Yellow;

		else if (_currentColor == PlayerColor.Yellow && _currentState==State.endRound) {
			round += 1;
			_stm.setRound(round);

			_currentColor = PlayerColor.Red;
			_stm.addRevenue(PlayerColor.Red);
			_stm.addRevenue(PlayerColor.Green);
			_stm.addRevenue(PlayerColor.Blue);
			_stm.addRevenue(PlayerColor.Yellow); 

		}	  


		if (round == 0) {
			_stm.setState(State.buy, false);
		} else {
			_stm.setState(State.move, false);
		}
		
		if (round == 25) {
			_stm.setState(State.gameover, false);
		}

		return  _currentColor;
	}

	public Player getPlayerInTurn() {
		return _stm.getPlayer(_currentColor);
	}

	public void setDeckOfCards(DeckOfCards deck) {
		// Gamevarient dosn't use af deck of cards is to be ignored according to interface  
	}


	//This gamevariant dosn't use a deck of cards. According to interface this 
	//mehod has to return the value -1
	public int getCurrentDeckBasedDiceValue() {
		return -1;
	}


	public void doUpdateDeck(DeckOfCards deck) {

	}


}

